package com.fmm.easy;

public class LongestDistanceHouses {

    public static int longestDistance(int[] colors) {
        return longestDistance(colors, 0, colors.length - 1);
    }

    private static int longestDistance(int[] colors, int start, int end) {
        if (start == end) {
            return 0;
        }
        if (colors[start] != colors[end]) {
            return end - start;
        }
        return Math.max(longestDistance(colors, start + 1, end),
                longestDistance(colors, start, end - 1));
    }
}
